<?php
//$a=rtrim(shell_exec('python /www/wwwroot/gdmovie.guadou.cyou/6v/getIP.py'));
$rooturl="http://localhost/api/pyToapi.php?page=play&playurl={$_GET['playId']}&id={$_GET['id']}&pathid1={$_GET['pathid1']}&bf={$_GET['bf']}";
$playurl=trim(file_get_contents($rooturl))."/index.m3u8";
// echo $rooturl;//真实的播放地址
session_start();//获取session指针
//var_dump();
?>
<!doctype html>
<html lang="zh-Han">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="index.css">
    <title><?php echo $_SESSION['playdataTitle'];?>-在线播放-瓜豆影院</title>
</head>
<body>
    <div class="play_videobox">
        <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
        <!-- Or if you want a more recent canary version -->
        <video id="video" style="width: 100%;height: auto" controls></video>
        <script>
            var video = document.getElementById('video');
            if(Hls.isSupported()) {
                var hls = new Hls();
                hls.loadSource("<?php echo $playurl; ?>");
                hls.attachMedia(video);
                hls.on(Hls.Events.MANIFEST_PARSED,function() {
                    video.play();
                });
            }else if (video.canPlayType('application/vnd.apple.mpegurl')) {
                video.src = "<?php echo $playurl; ?>";
                video.addEventListener('loadedmetadata',function() {
                    video.play();
                });
            }
        </script>
    </div>

    <div class="detailplaybox">

        <div class="detailplaytap">
            <?php
            $playurl=json_decode(json_encode($_SESSION['playdataUrl'],True),True);
            for ($i = 0; $i <= count($playurl[$i]); $i++) {
                echo "<p><p_title>{$playurl[$i]["playlist"]}</p_title></p>";
                $itemurl=json_decode(json_encode($playurl[$i]['itemurl'],True),True);
                for ($j = 0; $j < count($itemurl); $j++) {
                    echo "<div class='detail_play_text'><a class='detail_play_text_text' href=\"/play.php?playId={$itemurl[$j]['url']}\">{$itemurl[$j]['item']}</a></div>";
                }
            }
            ?>
        </div>
    </div>

</body>
</html>
